package com.timothy.android.chart;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.AdapterView;


public class AndroidChartActivity extends Activity {
    /** Called when the activity is first created. */
	
	private ListView listView;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        listView = new ListView(this);
        listView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_expandable_list_item_1,getData()));
        setContentView(listView);
        
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener(){
			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				
				//go to home page
				Intent intent = new Intent();
				switch (arg2) {
				case 0:
					intent.setClass(getBaseContext(),Bar2DVerticalActivity.class);
					break;
				default:
					intent.setClass(getBaseContext(), AndroidChartActivity.class);
					break;
				}

				startActivity(intent);
			}
        	
        });
        
    }
 
    private List<String> getData(){
    	List<String> groups = new ArrayList<String>();
		//test data
		groups.add("Chart-2DBar-Ver");
		groups.add("Chart-2DBar-Hon");
		groups.add("Chart-3DBar-Ver");
		groups.add("Chart-3DBar-Hon");
		groups.add("Chart-Cylinder-Ver");
		groups.add("Chart-Cylinder-Hon");
    	return groups;
   }
    
    //重写onListItemClick但是ListView条目事件
/*	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		// TODO Auto-generated method stub
		super.onListItemClick(l, v, position, id);
		//显示单击条目ID号
		System.out.println("id = " + id);
		//显示所单击条目的位置数
		System.out.println("position = " + position);
	}*/
}